package com.briup.day11;

import java.util.Arrays;

/**
 * @author lining
 * @date 2024/1/22 11:33
 */
public class TestGender {
    public static void main(String[] args) {
        //1.获取到枚举对象
        System.out.println(Gender.MALE);
        System.out.println(Gender.FEMALE);
        Gender g = Gender.MALE;
        System.out.println(g == null);
        System.out.println(g instanceof Gender);
        //2.调用方法(自己方法)
        Gender[] values = Gender.values();
        System.out.println("所有的枚举对象信息："+Arrays.toString(values));
        Gender g2 = Gender.valueOf("MALE");
        System.out.println(g2 == null);
        System.out.println("g== g2:"+(g == g2));
        //调用抽象父类中继承的方法（Enum）
        Enum e = Gender.MALE;
        System.out.println(e.name());//对象名
        System.out.println(e.ordinal());//序号信息
        System.out.println(Gender.FEMALE.ordinal());
        //调用枚举类中自定义方法
        String name = Gender.MALE.getName();
        System.out.println("性别："+name);
    }
}
